package com.orangelife.arenasdk.biz;

import com.curry.android.http.VolleyHttpUtil;

import org.json.JSONObject;

import java.util.HashMap;

/**
 * <p>
 * Created by 吴格非 on 2016-10-9.
 * <p>
 *
 * @author 吴格非
 * @since v1.0.0
 */

public class ArenaBiz {

    public static String HOST = "http://10.168.7.1:8088";
//    private static final String HOST = "http://10.168.7.1:8080";

    private static final String URL_INIT = "/arena/app/game/{gameID}/init";
    private static final String URL_EVENT = "/arena/app/room/{roomID}/event";
    private static final String URL_RANK = "/arena/app/game/{gameID}/rank";


    public static void httpInit(String gameID, VolleyHttpUtil.ResponseCallBack callback) {
        HashMap<String, String> urlMap = new HashMap<>();
        urlMap.put("{gameID}", gameID);
        HashMap<String, Object> jsonMap = new HashMap<>();
        VolleyHttpUtil.getInstance().postWithCallback(HOST + URL_INIT, urlMap, jsonMap, callback);
    }

    public static void httpEvent(String data, String roomID, VolleyHttpUtil.ResponseCallBack callback) {
        HashMap<String, String> urlMap = new HashMap<>();
        urlMap.put("{roomID}", roomID);
        HashMap<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("data", data);
        VolleyHttpUtil.getInstance().postWithCallback(HOST + URL_EVENT, urlMap, jsonMap, callback);
    }

    public static void httpRank(String gameID, String pageIndex, String pageSize, VolleyHttpUtil.ResponseCallBack callback) {
        HashMap<String, String> urlMap = new HashMap<>();
        urlMap.put("{gameID}", gameID);
        urlMap.put("pageNum", pageIndex);
        urlMap.put("pageSize", pageSize);
        VolleyHttpUtil.getInstance().getWithCallback(HOST + URL_RANK, urlMap, callback);
    }

}
